PreLab 08


Due in class on Wednesday, November 4

Here are two questions that don't have much to do with Lab 08. This is another opportunity to get practice wrting code on paper.

  1. Write a program with two input loops. The first loop asks the user to enter a date. If the user enters anything but an empty string, the program then asks for the name of a person who has a birthday on that date. This continues until the user gives an empty string for the date. The second loop also asks for a date. If it gets the empty string the program terminates. If it gets an actual date it prints the names of all of the people it knows who have birthdays on that date. If it doesn't know anyone with a birthday on that date, it says so.

    Since you are doing this on paper, let's keep the input as simple as possible. The names can be arbitrary strings. For the dates, expect the user to write them in a format such as 11, 4 (for November 4). If you input that into variable dateString, you can turn it into a tuple with
                                 date = eval(dateString)
    This means you can handle reading dates with code such as

                                 dateString = input( "date? " )
                                 if dateString == "":
                                           done = True
                                 else:
                                           date = eval(dateString)

  2. Write a function onlyLowerCase(s) that takes as an argument a string. The function should return a new string consisting of only the lower case letters of s. All of the capital letters, punctuation and spaces in s should be removed from the output. For example, onlyLowerCase( "I read the news today, Oh boy!" ) should return "readthenewstodayhboy".

Honor Code

If you followed the Honor Code in this assignment, write the following sentence attesting to the fact at the top of your homework.

I affirm that I have adhered to the Honor Code in this assignment.